<template>
  <div>
    <el-dialog
      :title="'操作'"
      :visible.sync="addEditIsDialog_c"
      @close="resetForm"
      width="50rem !important"
    >
    <div class="btn-box">
     <el-button style="height:9rem;width:9rem;font-size: 1.7rem;" :type="ruleForm.status == 1 ? 'primary' : ''" @click="submitForm(1)">过滤</el-button>
     <el-button style="height:9rem;width:9rem;font-size: 1.7rem;" :type="ruleForm.status == 2 ? 'primary' : ''" @click="submitForm(2)">冲洗</el-button>
     <el-button style="height:9rem;width:9rem;font-size: 1.7rem;" :type="ruleForm.status == 0 ? 'primary' : ''" @click="submitForm(0)">停用</el-button>
    </div>
    </el-dialog>
  </div>
</template>
<script type="text/ecmascript-6">
import { cmdControlDeviceGroupUnit } from "@/api/filtration";

export default {
  components: {
  },
  props: {
    operationId: {
      type: String,
      default: "",
    },
    operationStatus: {
      type: Number,
      default: 0,
    },
    operationIsDialog: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      ruleForm: {
        // 表单字段
        id: "",
        status:0,
      },
      rules: {
        // 表单规则
      },
      addEditIsDialog_c: false, // 弹窗是否显示
    };
  },
  watch: {
    operationIsDialog(val) {
      this.addEditIsDialog_c = val;
      if (this.addEditIsDialog_c) {
          this.ruleForm.id = this.operationId + "";
          this.ruleForm.status = this.operationStatus;
      }
    },
  },
  methods: {
    // 提交
    submitForm(status) {
      this.ruleForm.status = status;
          cmdControlDeviceGroupUnit(this.ruleForm).then((res) => {
            if (res.code == 200) {
              this.$message({
                type: "success",
                message: res.msg,
              });

              // 关闭弹窗
              this.$parent.closeAddEdit();
              // 刷新列表
              this.$parent.getControlDeviceGroupUnits();
            }
          });
    },
    // 取消
    resetForm() {
      this.$parent.closeAddEdit();
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-dialog__header{
 background-color: #0863B3;
 .el-dialog__title{
  color: white;
  font-size: 1.5rem !important;
 }
 .el-dialog__close{
  font-size: 1.7rem !important;
 }
}
.btn-box{
   width: 100% !important;
   height: 30rem !important;
   display: flex;
   align-items: center;
   justify-content: space-around;
}
</style>
